package com.ywm.mapper;

import com.ywm.dto.TopUser;
import com.ywm.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface UserMapper extends BaseMapper<User> {
    /**
     *返回发表量前五的作者
     * @return 返回发表量前五的作者
     */
    @Select("SELECT a.user_id as userId,a.name as userName,a.header,b.blogCount from user a join (select author,COUNT(*) as blogCount from blog GROUP BY author) b on a.name=b.author ORDER BY  blogCount DESC")
    List<TopUser>  getTopFiveUser();
}
